import Router from "koa-router";

import {
  getUsersValidator,
  createUserValidator,
  userIdValidator,
  updateUserValidator
} from "../validator/user";
import {
  getUsers,
  createUser,
  getUser,
  deleteUser,
  updateUser
} from "../controller/user";

const router = new Router();

// 获取所有用户
router.get("/users", ...getUsersValidator, getUsers);

// 获取单个用户
router.get("/users/:id", ...userIdValidator, getUser);

// 新增用户
router.post("/users", ...createUserValidator, createUser);

// 更新用户信息
router.put("/users/:id", ...userIdValidator, ...updateUserValidator, updateUser);

// 删除单个用户
router.delete("/users/:id", ...userIdValidator, deleteUser);

export { router as default };
